package com.ruoyi.web.controller.biz;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.BizAuthorize;
import com.ruoyi.system.domain.BizCustomer;
import com.ruoyi.system.service.BizAuthorizeService;
import com.ruoyi.system.service.BizCustomerService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/biz/customer")
public class BizCustomerController extends BaseController {

    @Resource
    private BizCustomerService customerService;

    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(BizCustomer bizCustomer) {
        startPage();
        List<BizCustomer> bizCustomerList = customerService.selectCustomerList(bizCustomer);
        return getDataTable(bizCustomerList);
    }

    @Anonymous
    @GetMapping(value = "/queryById")
    public AjaxResult queryById(@RequestParam("id") Long id) {
        return success(customerService.selectCustomerById(id));
    }

    @Anonymous
    @PostMapping("/save")
    public AjaxResult save(@RequestBody BizCustomer bizCustomer) {
        return toAjax(customerService.insertCustomer(bizCustomer));
    }

    @Anonymous
    @PutMapping("/update")
    public AjaxResult update(@RequestBody BizCustomer bizCustomer) {
        return toAjax(customerService.updateCustomer(bizCustomer));
    }

    @Anonymous
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable("id") Long id) {
        return toAjax(customerService.deleteCustomerById(id));
    }

    @GetMapping("/queryByCondition")
    public TableDataInfo queryByCondition(BizCustomer bizCustomer) {
        startPage();
        List<BizCustomer> customerList = customerService.selectCustomerList(bizCustomer);
        return getDataTable(customerList);
    }


}
